<div class="row" style="margin-top:1rem;">
    <div class="logo-colored text-center medium-12 column">
        <a href="<?= BASE_URI?>feeds"><img src="<?php echo BASE_URI; ?>img/icons/logo2.png" style='height:100%;width:15rem;'></a>
        <p style="color:gray;font-size:1.8rem;">Connecting people at home.</p>
    </div>

<form id="frmAdminLogin" data-abide="ajax" method="post">
    <div class="medium-3 medium-centered columns" style="margin-top:9rem;">
      <div class="text-center signup-panel">
        <form>
          <div class="row">
            <div class="small-12  columns">
              <input name="username" type="text" placeholder="Username or Email" required>
              <small class="regerr error" style=""><i class="fa fa-exclamation-circle fa-lg" style="color:#E8877D"></i> Email is required</small>
            </div>
          </div>
          <div class="row">
            <div class="small-12 columns ">
              <input name="password" type="password" placeholder="Password" required>
              <small class="regerr error" style=""><i class="fa fa-exclamation-circle fa-lg" style="color:#E8877D"></i> Password is required</small>
            </div>
            
          </div>
        </form>
        <a href="#" class="radius expand button btnAdminLogin">Login </a>
      </div>
    </div>
</form>
</div>              

<script type="text/javascript">
$(function(){
    function login(data){
       var params = {};
       params.data = data;
       return $.ajax({
          url: URL + 'adminapi/login',
          data: params,
          type: 'post',
          dataType: 'json'
       });
    }
    $(document).ready(function(){
        $('#frmAdminLogin').on('valid',function(event){
            var data = $(this).serialize();
            $('.btnAdminLogin').html('Logging in please wait.. <img src="<?=BASE_URI?>img/loading.gif"/>');
            login(data).done(function(result){
                if(result.status){
                    window.location.replace(URL + 'admin');
                }else{
                   if(!result.messages){
                      $('.btnAdminLogin').html('Login');
                      alert('Incorrect Username/Password');
                   }else{
                      alert(result.messages);
                      $('.btnAdminLogin').html('Login');
                   }
                   
                }
            });
        });
        $(document).on('click','.btnAdminLogin',function(){
            $('#frmAdminLogin').submit();
        });
    });
});
    
</script>